# Reference: <https://postmarketos.org/devicepkg>
pkgname=device-google-bonito
pkgdesc="Google Pixel 3a XL"
pkgver=4
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="aarch64"
options="!check !archcheck"
depends="
	alsa-ucm-conf-qcom-sdm670
	make-dynpart-mappings
	mkbootimg
	postmarketos-base
	soc-qcom-sdm845
	soc-qcom-sdm845-qbootctl
"
makedepends="devicepkg-dev"
source="
	90-feedbackd-drv2624.rules
	deviceinfo
	modules-initfs
	q6voiced.conf
"
subpackages="
	$pkgname-kernel-sdc:kernel_sdc
	$pkgname-kernel-tianma:kernel_tianma
	$pkgname-nonfree-firmware:nonfree_firmware
"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname

	install -Dm644 "$srcdir"/90-feedbackd-drv2624.rules \
		-t "$pkgdir"/usr/lib/udev/rules.d
}

kernel_sdc() {
	pkgdesc="Kernel for devices with the Samsung panel"
	depends="linux-postmarketos-qcom-sdm670"

	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

kernel_tianma() {
	pkgdesc="Kernel for devices with the Tianma panel"
	depends="linux-postmarketos-qcom-sdm670"

	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

nonfree_firmware() {
	pkgdesc="Proprietary firmware blobs for the Google Pixel 3a XL"
	depends="
		firmware-google-sargo
		linux-firmware-ath10k
		linux-firmware-qca
		linux-firmware-qcom
		soc-qcom-sdm845-modem
		soc-qcom-sdm845-nonfree-firmware
	"

	# The q6voiced configuration can only be used if the ADSP is brought up
	# via non-free firmware.
	install -Dm644 "$srcdir"/q6voiced.conf "$subpkgdir"/etc/conf.d/q6voiced
}

sha512sums="
016d398155f2344417f5e5649a361719ba6e53e593c501b5df39114cdd284302b9bf8686a39817aee0c08fec95b3ab613c181d6cc9596299aaf7fd05dbe0c3dd  90-feedbackd-drv2624.rules
e417f9a4da0dd595e34c520c10aef89e480336d9d57b66284a98777afce1dbc3dcda30f8a3a1c625b5e5e19aae4a95f28e00ca47e5d0e993ca922da5107bd837  deviceinfo
1eb5f138619f499fab31ea64f63ee9f8984f195528708ec6a01ddc533c74cfb71d1442b97905ae15db24b8faac259fa3e89db357ca9c747ce3ee598c2d681639  modules-initfs
3a4a9322839d4b3ef9d79668a37840a9f444954759ae3c512e694051d2f9a2573db42ad6c4c1a5c75eeb861232a27ba1a8cef9b503decd54ead25a96e3dd6f98  q6voiced.conf
"
